package com.mall4j.cloud.user.mapper;

import com.mall4j.cloud.user.model.UserCards;
import org.apache.ibatis.annotations.*;

import java.util.List;


public interface UserCardsMapper {



    @Insert("INSERT INTO user_cards(user_id, card_num, status, bank) " +
            "VALUES(#{userId}, #{cardNum}, #{status}, #{bank})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void insertUserCards(UserCards userCards);

    @Select("SELECT * FROM user_cards WHERE user_id = #{userId}")
    List<UserCards> getUserCardsByUserId(Long userId);

    @Select("SELECT * FROM user_cards")
    List<UserCards> getAllUserCards();

    @Update("UPDATE user_cards SET user_id = #{userId}, update_time = #{updateTime}, " +
            "card_num = #{cardNum}, status = #{status}, bank = #{bank} WHERE id = #{id}")
    void updateUserCards(UserCards userCards);

    @Delete("DELETE FROM user_cards WHERE id = #{id}")
    void deleteUserCardsById(Long id);
}
